using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassifierLib.Classifier.Filters
{
    /// <summary>
    /// filter rules that match the current input
    /// </summary>
    public class Match : RuleFilter
    {
        public Match()
        {
            this.Name = "Match";
            if (!RegisteredTypes.Contains(GetType()))
                RegisteredTypes.Add(GetType()); 
        }

        public override Population Apply(Population Population, Population PopSet, Environment.State State, Action Action)
        {
            Population MatchSet = new Population();

            foreach (Rule r in Population)
            {
                if (r.Condition.Matches(State))
                {
                    MatchSet.Add(r);
                }
            }

            return MatchSet;
        }
    }
}
